import axios from 'axios'
import qs from 'qs'

axios.defaults.baseURL = 'http://127.0.0.1:5000'

const maxios = function(url,method,data={}){
    return new Promise((resolve)=>{
        if(method == 'get' || method == 'delete'){
            axios({
                'method':method,
                'url':url,
                'params':qs.stringify(data)
            }).then(res=>{
                resolve(res.data)
            })
        }else{
            axios({
                'method':method,
                'url':url,
                'data':qs.stringify(data)
            }).then(res=>{
                resolve(res.data)
            })
        }
    })

}


export default maxios